<%@ page pageEncoding="UTF-8"%>
<%@include file="/util/tag.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

     <%@include file="../common/head.jsp"%>
     
        <script language="javascript" type="text/javascript">
            //显示角色详细信息
            function showDetail(flag, a) {
                var detailDiv = a.parentNode.getElementsByTagName("div")[0];
                if (flag) {
                    detailDiv.style.display = "block";
                }
                else
                    detailDiv.style.display = "none";
            }
            //删除
            function deleteAccount(id) {
                var r = window.confirm("确定要删除此业务账号吗？删除后将不能恢复。");
                if(!r)	return;
                var b = request('delete?id='+id,'删除成功！','删除失败! 数据并发错误。',$("#operate_msg"));
                if(!b){
                	$("#operate_result_info").attr("class","operate_fail");
                	}
                document.getElementById("operate_result_info").style.display = "block";
            }
            //开通或暂停
            function setStateOn(id) {
                var r = window.confirm("确定要开通此业务账号吗？");
                if(!r)	return;
                var b = request('state?status=0&id='+id,'开通成功！','开通失败! 该账户被暂停无法开通业务！。',$("#operate_msg"));
                if(!b){
                	$("#operate_result_info").attr("class","operate_fail");
                	}
                document.getElementById("operate_result_info").style.display = "block";
                
            }
            function setStateDown(id) {
                var r = window.confirm("确定要暂停此业务账号吗？");
                if(!r)	return;
                var b = request('state?status=1&id='+id,'暂停成功！','暂停失败!数据并发错误。',$("#operate_msg"));
                if(!b){
                	$("#operate_result_info").attr("class","operate_fail");
                	}
                document.getElementById("operate_result_info").style.display = "block";
                }
        
            function search(){
            	var url="list?"+$("#idcard").serialize()+'&'+
            	$('#username').serialize()+"&"+
            	$("#host").serialize()+"&"+
            	$("#status").serialize();
            	location.href=url;
            }
        </script>
    <body>
        <%@include file="../common/top.jsp"%>
        
        <div id="main">
            <form action="" method="post">
                <!--查询-->
                <div class="search_add">                        
                    <div>OS 账号：<input name="usernamesh" value="${usernamesh}"id="username" class="width100 text_search" /></div>                            
                    <div>服务器 IP：<input name="hostsh" value="${hostsh}"id="host" class="width100 text_search" /></div>
                    <div>身份证：<input name="idcardsh" value="${idcardsh}"id="idcard" class="text_search" /></div>
                    <div>状态：
                         <s:select list="#{'':'全部','0':'开通','1':'暂停','2':'删除'}" cssClass="select_search"
                        name="statussh" id="status"></s:select>
                    </div>
                    <div><input type="button" value="搜索" class="btn_search" onclick="search();"/></div>
                    <input type="button" value="增加" class="btn_add" onclick="location.href='toAdd';" />
                </div>  
                <!--删除的操作提示-->
                <div id="operate_result_info" class="operate_success">
                    <img src="../images/close.png" onclick="this.parentNode.style.display='none';location.reload();" />
                   	<span id="operate_msg">删除成功！</span>
                </div>   
                <!--数据区域：用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                    <tr>
                        <th class="width50">业务ID</th>
                        <th class="width70">账务账号ID</th>
                        <th class="width150">身份证</th>
                        <th class="width70">姓名</th>
                        <th>OS 账号</th>
                        <th class="width50">状态</th>
                        <th class="width100">服务器 IP</th>
                        <th class="width100">资费</th>                                                        
                        <th class="width200"></th>
                    </tr>
                    <s:iterator value="serviceList">
                    <tr>
                        <td><a href="detail?usernamesh=${usernamesh }&hostsh=${hostsh }&idcardsh=${idcardsh }&statussh=${statussh }&id=${id}" title="查看明细">${id}</a></td>
                        <td>${account.id}</td>
                        <td>${account.idcardNo}</td>
                        <td>${account.realName}</td>
                        <td>${osUsername}</td>
                        <td>${statusOptions[status]}</td>
                        <td>${unixHost}</td>
                        <td>
                            <a class="summary"  onmouseover="showDetail(true,this);" onmouseout="showDetail(false,this);">${cost.name}</a>
                            <!--浮动的详细信息-->
                            <div class="detail_info">
                                ${cost.descr}
                            </div>
                        </td>                            
                        <td class="td_modi">
                        <s:if test="status!=2">
																			<s:if test="status==0">
																				<input type="button" value="暂停" class="btn_pause"	onclick="setStateDown(${id});" />
																			</s:if>
																			<s:else>
																				<input type="button" value="开通" class="btn_start"	onclick="setStateOn(${id});" />
																			</s:else>
																			<input type="button" value="修改" class="btn_modify" onclick="location.href='load?id=${id}';" />
                            <input type="button" value="删除" class="btn_delete" onclick="deleteAccount(${id});" />
                        </s:if> 
                        </td>
                    </tr>
                	</s:iterator>                                         
                </table>                
                <p>业务说明：<br />
                1、创建即开通，记载创建时间；<br />
                2、暂停后，记载暂停时间；<br />
                3、重新开通后，删除暂停时间；<br />
                4、删除后，记载删除时间，标示为删除，不能再开通、修改、删除；<br />
                5、业务账号不设计修改密码功能，由用户自服务功能实现；<br />
                6、暂停和删除状态的账务账号下属的业务账号不能被开通。</p>
                </div>                    
                <!--分页-->
                <div id="pages">
                    <a href="?usernamesh=${usernamesh }&hostsh=${hostsh }&idcardsh=${idcardsh }&statussh=${statussh }&page=1">首页</a>
        	        <s:if test="page>1">
        	        <a href="?usernamesh=${usernamesh }&hostsh=${hostsh }&idcardsh=${idcardsh }&statussh=${statussh }&page=${page-1}">上一页</a>
        	        </s:if><s:else><a>上一页</a></s:else>
        	        <s:iterator begin="1" end="pageCount" var="i">
                    <a href="?usernamesh=${usernamesh }&hostsh=${hostsh }&idcardsh=${idcardsh }&statussh=${statussh }&page=${i}" <c:if test="${page==i}">class="current_page"</c:if> >${i}</a>
                 </s:iterator>
                 <s:if test="page<pageCount">
        	        <a href="?usernamesh=${usernamesh }&hostsh=${hostsh }&idcardsh=${idcardsh }&statussh=${statussh }&page=${page+1}">下一页</a>
        	        </s:if><s:else><a>下一页</a></s:else>
                    <a href="?usernamesh=${usernamesh }&hostsh=${hostsh }&idcardsh=${idcardsh }&statussh=${statussh }&page=${pageCount}">末页</a>
                </div>                    
            </form>
        </div>
        
        <%@include file="../common/bottom.jsp"%>
    </body>
</html>
